/**
 * 获取元素
 */

let registerInp = document.querySelectorAll('.register-inp input')
let Tips = document.querySelectorAll('.Tips')
let registerGo = document.querySelector('.register-go button')
let check = document.querySelector('.check input')


// 将验证规则组装成一个数组

let arr = [
        /^[a-zA-Z][a-zA-Z0-9_]{5,11}$/,
        /^1[345678][0-9]{9}$/,
        /^[a-zA-Z][a-zA-Z0-9_]{3}$/,
        /^[a-zA-Z][a-zA-Z0-9_]{5,11}$/
]

registerInp.forEach(function(dom,i){
    dom.addEventListener('blur',function(){
        let bool =arr[i].test(dom.value)
        
        if (bool) {
            Tips[i].style.display = 'none'
        }else{
            Tips[i].style.display = 'block'
        }
    })
})




registerGo.addEventListener('click',function(){
    
    for(let i =0;  i <registerInp.length;i++){
        let bool =arr[i].test(registerInp[i].value)
        
        if (bool) {
            Tips[i].style.display = 'none'
        }else{
            Tips[i].style.display = 'block'
            return;
        }
   
    }
  
        
   
})

// 取消禁用

check.addEventListener('click',function(){
    if (check.checked) {
        registerGo.classList.add('btn')
        registerGo.disabled = false
    }else{
        registerGo.classList.remove('btn')
        registerGo.disabled = true
    }
})